/* eslint-disable */
import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import formCreate from '@form-create/element-ui'
import FcDesigner from '@form-create/designer'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons'
import '@/permission'

// 图片预览组件
import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
Vue.use(VueViewer,{
    defaultOptions:{
        zIndex:1002,
        keyboard:true,
    }
})

Vue.use(ElementUI, {
    locale,
    size: 'small'
})
Vue.use(formCreate)
Vue.use(FcDesigner)

import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload, {
    // error: require('../public/images/img_default.png'),
    // loading: require('../public/images/image_loading.png')
})

import echarts from 'echarts'
Vue.prototype.$echarts = echarts

import uploader from 'vue-simple-uploader'
Vue.use(uploader)

/*
 * 公共JS
 */
import '@/utils'
import '@/assets/iconfont/iconfont.css'
/**
 * 公共弹框
 */
Vue.prototype.msgSuccess = function(msg) {
    this.$message({ showClose: true, message: msg, type: 'success' })
}
Vue.prototype.msgError = function(msg) {
    this.$message({ showClose: true, message: msg, type: 'error' })
}
Vue.prototype.msgWarning = function(msg) {
    this.$message({ showClose: true, message: msg, type: 'warning' })
}

import defaultSettings from '@/settings'
Vue.prototype.defaultSettings = defaultSettings
    /**
     * 系统错误捕获
     */
Vue.config.errorHandler = (err, vm) => {
    console.error(err)
    ElementUI.Notification({
        type: 'error',
        title: 'JS异常',
        dangerouslyUseHTMLString: true,
        message: '<m style="color:red">按F12查看错误信息</m><br>请将错误信息发送给管理员进行处理'
    })
}
Vue.prototype.handleImageError = function(e) {
    let title
    if (e.target.title && e.target.title) {
        title = e.target.title.substring(0, 1)
    }
    e.target.src = Vue.prototype.common.generateTextPictures(title)
}

Vue.prototype.$FILE_SERVER=(process.env.NODE_ENV === 'development' ? process.env.VUE_APP_BASE_API : window.g.baseURL)
Vue.prototype.formCreaterUploadSuccess=function(e,t){
    if(e.code===200){
        t.url=e.data.uuid
        this.$message({ showClose: true, message: '上传成功!', type: 'success' })
    }else{
        this.$message({ showClose: true, message: e.data==null?e.message:e.data, type: 'warning' })
    }
}

import 'bpmn-js/dist/assets/diagram-js.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css'

Vue.config.productionTip = false
new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
})